<template>
  <section class="n-section-container" :class="{ 'dis-flex': flex, 'flex-dir-column': flexColumn }">
    <div class="n-section-header" v-if="title">
      <h4 class="n-section-title text-nowrap">
        <div class="n-section-arrow"></div>
        {{ title }}
        <template v-if="$slots.count">
          <span class="count">
            (
            <slot name="count" />
            )
          </span>
        </template>
      </h4>
      <div v-if="$slots.headerright"><slot name="headerright" /></div>
    </div>
    <div v-if="$slots.default" class="n-section-content" :class="[{ 'form-content': form, 'scroll-x': scrollX }, classScrollY]"><slot /></div>
  </section>
</template>
<script setup>
  import { computed } from "vue"
  /**
   * props
   */
  const props = defineProps({
    title: {
      type: String,
      default: "",
    },
    flex: Boolean,
    flexColumn: Boolean,
    form: Boolean,
    scrollX: Boolean,
    scrollY: Boolean,
  })

  const classScrollY = computed(() => (props.scrollY ? "scroll-y flex-1 h0" : ""))
</script>
<style lang="scss">
  .n-section-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 44px;
    padding: 0 16px 0 40px;
    background-color: var(--n-black-bg);
  }
  .n-section-title {
    margin-bottom: 0;
    font-family: "PF-Medium";
    font-weight: 600;
  }
  .form-content {
    margin-left: 215px;
  }
  .n-section-content {
    padding: 16px 0 20px 40px;
  }
  .n-section-arrow {
    position: absolute;
    width: 14px;
    height: 14px;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    background-color: #ccc;
  }
</style>
